]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspacesView: Center extra workspace
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 20 Feb 2021 12:33:29 +0000 (13:33 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 2 Mar 2021 21:56:30 +0000 (21:56 +0000)
At the moment views on non-primary monitors take up the entire work area,
so simply allocating the available size works. However we'll soon shrink
the views a bit to match the visuals on the primary monitor. As workspaces
keep the ratio, reducing their height will also reduce the width; override
the default allocate() to keep the extra workspace horizontally centered.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1735>

js/ui/workspacesView.js

index fb9eafb0a8f2aabf3302eb18bc019c6d1666b59b..b65d887245850aee4e76eaaa412613adcc42ae8c 100644 (file)
@@ -560,6 +560,18 @@ class ExtraWorkspaceView extends WorkspacesViewBase {
         this._workspace.stateAdjustment.value = progress;
     }
 
+    vfunc_allocate(box) {
+        this.set_allocation(box);
+
+        const [width, height] = box.get_size();
+        const [, childWidth] = this._workspace.get_preferred_width(height);
+
+        const childBox = new Clutter.ActorBox();
+        childBox.set_origin(Math.round((width - childWidth) / 2), 0);
+        childBox.set_size(childWidth, height);
+        this._workspace.allocate(childBox);
+    }
+
     getActiveWorkspace() {
         return this._workspace;
     }